package xin.marcher.sentinel.extension.file;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

/**
 * Sentinel 规则持久化常量配置
 *
 * @author marcher
 */
public class PersistenceRuleConstant {

    /**
     * 存储文件路径
     */
    public static final String STORE_PATH = System.getProperty("user.home") + File.separator + "sentinel" + File.separator + "rules";

    /**
     * 各种存储sentinel规则映射map
     */
    public static final Map<String, String> RULES_MAP = new HashMap<>();

    /** 流控规则文件 */
    public static final String FLOW_RULE_PATH = "flowRulePath";

    /** 降级规则文件 */
    public static final String DEGRAGE_RULE_PATH = "degradeRulePath";

    /** 授权规则文件 */
    public static final String AUTH_RULE_PATH = "authRulePath";

    /** 系统规则文件 */
    public static final String SYSTEM_RULE_PATH = "systemRulePath";

    /** 热点参数文件 */
    public static final String HOT_PARAM_RULE = "hotParamRulePath";

    static {
        RULES_MAP.put(FLOW_RULE_PATH, STORE_PATH + File.separator + "flowRule.json");
        RULES_MAP.put(DEGRAGE_RULE_PATH, STORE_PATH + File.separator + "degradeRule.json");
        RULES_MAP.put(SYSTEM_RULE_PATH, STORE_PATH + File.separator + "systemRule.json");
        RULES_MAP.put(AUTH_RULE_PATH, STORE_PATH + File.separator + "authRule.json");
        RULES_MAP.put(HOT_PARAM_RULE, STORE_PATH + File.separator + "hotParamRule.json");
    }
}
